package com.cn.wanxi.servlet.user;

import com.alibaba.fastjson.JSONObject;
import com.cn.wanxi.model.ResultModel;
import com.cn.wanxi.model.UserModel;
import com.cn.wanxi.service.UserService;
import com.cn.wanxi.service.impl.UserServiceImpl;
import com.cn.wanxi.util.Tool;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/back/user/sex")
public class UserUpdateSexServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String id = req.getParameter("id");
//        以后我们参数最好全是对象，因为如果用属性作为参数，有可能以后会增加参数的个数
        UserModel model = new UserModel();
        model.setId(Tool.strToInt(id));

        UserService userService = new UserServiceImpl();


        ResultModel resultModel = userService.updateSex(model);
        resp.getWriter().println(JSONObject.toJSONString(resultModel));
    }
}
